package io.renren.modules.oss.cloud;
import com.qiniu.storage.Configuration;
import com.qiniu.common.Zone;
import com.qiniu.storage.BucketManager;
import com.qiniu.util.Auth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class BucketManagerConfig {
    @Autowired
    private CloudStorageConfig config;

    @Bean
    public BucketManager bucketManager(){
        Configuration cfg = new Configuration(Zone.zone0());
        Auth auth = Auth.create(config.getQiniuAccessKey(), config.getQiniuSecretKey());
        BucketManager bucketManager = new BucketManager(auth, cfg);
        return bucketManager;
    }

}
